/*
 * @Date: 2025-06-12 10:56:57
 * @LastEditors: lyx
 * @LastEditTime: 2025-06-12 10:57:05
 * @FilePath: \blog\src\plugins\remark-reading-time.js
 * @Description: 文章阅读时长插件
 */
import getReadingTime from "reading-time";
import { toString } from "mdast-util-to-string";

export function remarkReadingTime() {
  return function (tree, { data }) {
    const textOnPage = toString(tree);
    const readingTime = getReadingTime(textOnPage);
    data.astro.frontmatter.minutesRead = Math.ceil(readingTime.minutes);
  };
}
